import os
import sys
import re

if __name__ == '__main__':

	friendPair_d = {}
	for row in sys.stdin:
		if row.strip() != '':
			host = row.split(':')[0]
			friends_l = row.split(':')[1].strip().split(' ')
			# print(host, friends_l)
			for a in range(0, len(friends_l)-1):
				for b in range(1, len(friends_l)):
					# friendPair_d[(friends_l[a], friends_l[b])] = host
					print(friends_l[a], friends_l[b], host)
	# print(friendPair_d)






   #  handler = sys.stdin
   #  # print(handler)
   #  for row in handler:
   # #  	if not row:
			# # print(row)
   #  	host = row.split(':')[0]
   #  	friends_l = row.split(':')[1].strip().split(' ') 
   #  	print(host, friends_l)

